﻿using System;
using System.Collections.Generic;
using System.Text;

using ET;
using Marx;

namespace Demo
{
    public abstract class PlayerInfo : Entity
    {
        public Player Owner { get { return Parent as Player; } }
        public long PlayerId { get { return Parent.Id; } }
        public bool Ready { get { return Owner.Ready; } }

        public virtual void OnAwake()
        {

        }

        public virtual void OnInitialize()
        {

        }

        public virtual async ETTask Checkout()
        {
            await ETTask.CompletedTask;
        }

        public virtual async ETTask Cleanup()
        {
            await ETTask.CompletedTask;
        }

        public void SendMessageToClient(IClientNotify message)
        {
            Owner.SendMessageToClient(message);
        }

        public void LogError(string content)
        {
            Log.Error($"Player[{ PlayerId }] : {content}");
        }

        public void LogDebug(string content)
        {
            Log.Debug($"Player[{ PlayerId }] : {content}");
        }

        public void LogInfo(string content)
        {
            Log.Info($"Player[{ PlayerId }] : {content}");
        }

        public void LogException(Exception e)
        {
            string msg = $"{e.Data["StackTrace"]} \n\n {e}";
            Log.Error($"Player[{ PlayerId }] : {msg}");
        }
    }
}
